<template>
  <page-body>
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center exchange_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub exchange_fd0_0'>
          <view class='flex flex-wrap align-center exchange_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  exchange_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='exchange_fd0_0_c1_c0'>兑换</text>
          </view>
          <view class='flex flex-wrap align-center justify-end exchange_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <view class='flex flex-direction flex-wrap align-stretch exchange_fd1_0'>
          <view class='flex flex-wrap align-center exchange_fd1_0_c0'>
            <input class='exchange_fd1_0_c0_c0' type="number" :placeholder="`兑换数量`" confirm-type="done"
              v-model="shuliang" @input="changeJ" :maxlength="5" :adjust-position='true'
              placeholder-style="color:#999;font-size:28rpx" />
            <text class='exchange_fd1_0_c0_c1'>平台币 ≈</text>
            <input class='exchange_fd1_0_c0_c2' type="number" :placeholder="`兑换金额`" confirm-type="done" v-model="jine"
              :maxlength="5" :adjust-position='true' placeholder-style="color:#999;font-size:28rpx" />
            <text class='exchange_fd1_0_c0_c3'>元</text>
          </view>
          <view class='flex flex-wrap align-center justify-between flex-sub exchange_fd1_0_c1'>
            <view class='flex flex-wrap align-center justify-between'>
              <text class='exchange_fd1_0_c1_c0_c0'>可兑换平台币数量：</text>
              <text class='exchange_fd1_0_c1_c0_c1'>{{Message.fadou}}</text>
            </view>
            <text @click.stop="chengAll">全部兑换</text>
          </view>
        </view>
        <view class='flex flex-direction flex-wrap align-stretch exchange_fd1_1'>
          <text>兑换说明：</text>
          <jyf-parser class='myMoney_fd2_0_c1_c0' :html="dataDetails.content | richTextFormat">
          </jyf-parser>
        </view>
        <button class='exchange_fd1_2' @click.stop="submit">确认兑换</button>
      </view>

      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1717061001971" :mask="true" :mask-close-able="true" mode='center' :z-index='999'>
        <!---flex布局flex布局开始-->
        <view class="flex benben-flex-layout bg-white flex-wrap align-center" style="border-radius: 16rpx;">
          <view class='flex flex-direction flex-wrap align-center flex-sub exchange_fd2_0'>
            <image class='exchange_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"20.png"'></image>
            <text class='exchange_fd2_0_c1'>兑换成功</text>
          </view>
        </view>
        <view class='flex flex-wrap align-center justify-center myMoney_fd2_1'>
          <image class='myMoney_fd2_1_c0' mode="aspectFit" :src='STATIC_URL+"101.png"'
            @tap.stop="popupShow1717061001971=false"></image>
        </view>
        <!---flex布局flex布局结束-->

      </benben-popup>


    </view>
  </page-body>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "popupShow1717061001971": false,
        Message: '',
        shuliang: 0,
        jine: 0,
        dataDetails: ''
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      this.getMessageFunc()
      this.getMoneyFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      closeBack() {
        this.popupShow1717061001971 = false
        uni.navigateBack()
      },
      async getMessageFunc() {
        //请求方法
        //数据验证

        let datadataDetails = await this.$api.get(global.apiUrls.post641568f1b6f87, {
          column_id: '23'
        });

        if (datadataDetails.data.code != 1) {
          this.$message.info(datadataDetails.data.msg);
          return
        }
        let infodataDetails = datadataDetails.data;
        this.dataDetails = infodataDetails.data

      },
      //钱包-钱包主页
      async getMoneyFunc() {
        //请求方法
        //数据验证

        let dataMessage = await this.$api.get(global.apiUrls.post5c78c4772da97, {

        });

        if (dataMessage.data.code != 1) {
          this.$message.info(dataMessage.data.msg);
          return
        }
        let infoMessage = dataMessage.data;
        this.Message = infoMessage.data
      },
      changeJ() {
        this.jine = parseFloat(this.shuliang) / parseFloat(this.Message.duihuan)
      },
      chengAll() {
        this.shuliang = this.Message.fadou
        this.jine = parseFloat(this.shuliang) / parseFloat(this.Message.duihuan)
      },
      submit() {
        if (!this.shuliang) {
          this.$message.info('请输入兑换数量')
          return
        }
        this.$api.dbPost(global.apiUrls.post665d38a9d3642, {
          coin: this.shuliang,
          money: this.jine
        }).then(res => {
          if (res.data.code == 1) {
            this.popupShow1717061001971 = true
          } else {
            this.$message.info(res.data.msg)
          }
        })
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% 100%;
  }

  .exchange_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .myMoney_fd2_1 {
    margin: 48rpx 0rpx 0rpx 0rpx;
  }

  .myMoney_fd2_1_c0 {
    width: 56rpx;
    height: 56rpx;
    border-radius: 28rpx 28rpx 28rpx 28rpx;
  }

  .exchange_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .exchange_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .exchange_fd0_0_c0 {
    width: 120rpx;
  }

  .exchange_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .exchange_fd1_2 {
    background: #5ECA71;
    border-radius: 50rpx 50rpx 50rpx 50rpx;
    width: 686rpx;
    line-height: 80rpx;
    font-size: 32rpx;
    color: #fff;
    position: fixed;
    bottom: calc(100rpx + var(--window-bottom));
    left: 32rpx;
    height: 80rpx;
  }

  .exchange_fd1_1_c1 {
    color: rgba(127, 127, 127, 1);
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .exchange_fd1_1 {
    width: 686rpx;
    margin: 0rpx auto 0rpx auto;
    font-size: 24rpx;
  }

  .exchange_fd1_0_c1_c0_c1 {
    color: rgba(245, 44, 85, 1);
  }

  .exchange_fd1_0_c1_c0_c0 {
    color: rgba(170, 170, 170, 1);
  }

  .exchange_fd1_0_c1 {
    font-size: 24rpx;
  }

  .exchange_fd1_0_c0_c3 {
    margin: 0rpx 0rpx 0rpx 12rpx;
  }

  .exchange_fd1_0_c0_c2 {
    background: rgba(246, 246, 246, 1);
    height: 61rpx;
    width: 200rpx;
    line-height: 61rpx;
    background-size: 100% auto;
    text-align: center;
    border-radius: 16rpx;
  }

  .exchange_fd1_0_c0_c1 {
    margin: 0rpx 12rpx 0rpx 12rpx;
  }

  .exchange_fd1_0_c0_c0 {
    background: #F6F6F6;
    width: 200rpx;
    border-radius: 12rpx 12rpx 12rpx 12rpx;
    line-height: 61rpx;
    text-align: center;
    height: 61rpx;
  }

  .exchange_fd1_0_c0 {
    line-height: 88rpx;
    height: 88rpx;
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .exchange_fd1_0 {
    background: #FFFFFF;
    padding: 24rpx;
    width: 686rpx;
    border-radius: 16rpx;
    background-size: 100% auto;
    margin: 24rpx auto 24rpx auto;
  }

  .exchange_fd2_0_c1 {
    color: #333;
    font-size: 36rpx;
    margin: 24rpx 0rpx 0rpx 0rpx;
    font-weight: 700;
  }

  .exchange_fd2_0_c0 {
    width: 250rpx;
    height: 180rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 100rpx 0rpx 0rpx 0rpx;
  }

  .exchange_fd2_0 {
    background: var(--benbenbgColor1);
    background-size: 100% auto;
    border-radius: 16rpx;
    width: 540rpx;
    height: 472rpx;
  }
</style>
